import java.sql.*;   // methods to process SQL commands
import java.util.ArrayList;
import java.util.Collections;

import javax.sql.*;  // ditto
//import org.postgresql.jdbc3.Jdbc3PoolingDataSource; // connection via JDBC to postgrSQL
import java.io.IOException;   // enable IOException objects & handling
import java.io.PrintWriter;   // enable PrintWriter (so can use .println())
import javax.servlet.http.*;  // provides servlet functionality
import javax.servlet.*;	      // ditto
import javax.*;



public class MovieList {
	private ResultSet movieList;
	private ResultSet movieListFeaturedStars;
	private int sizeOfMovieList;
	private int start;
	private String order;
	private String orderType;
	private String movieListType;
	private String query ;
	private String currentGenre;
	private String state;
	private String queryFeaturedStars;

	public MovieList()
	{
		start =0;
		sizeOfMovieList = 0;
		order = Constants.ASCENDING;
		orderType = Constants.ORDER_BY_TITLE;
		movieListType = "";
		query = "";
		currentGenre = "";
		movieList = null;
		state = "firstPage";
		queryFeaturedStars = "";
		movieListFeaturedStars = null;
	}
	public void setRS(ResultSet set)
	{
		try 
		{
			movieList = set;
			movieList.last();
			sizeOfMovieList = movieList.getRow();
			movieList.beforeFirst();
		} catch (Exception e)
		{
			System.out.println("Exception inside MovieList: " + e.getMessage());
		}
	}
	public void setRSFeaturedStars(ResultSet set)
	{
		try 
		{
			movieListFeaturedStars = set;
			//movieList.last();
			//sizeOfMovieList = movieList.getRow();
			//movieList.beforeFirst();
		} catch (Exception e)
		{
			System.out.println("Exception inside MovieList featured stars: " + e.getMessage());
		}
	}
	public void setQueryFeaturedStars(String queryFeaturedStars)
	{
		this.queryFeaturedStars = queryFeaturedStars;
	}
	public void setQuery(String query)
	{
		this.query = query;
	}
	public void setStartIndex(int start)
	{
			this.start = start;
	}
	public void setMovieListType(String movieListType)
	{
		this.movieListType = movieListType;
	}
	public void setCurrentGenre(String currentGenre)
	{
		this.currentGenre = currentGenre;
	}
	public void reverseOrder()
	{
		if(order.equals(Constants.ASCENDING))
			order = Constants.DESCENDING;
		else
			order = Constants.ASCENDING;
	}
	public void setOrderType(String orderType)
	{
		this.orderType = orderType;
		order = Constants.ASCENDING;
	}
	public void setOrder(String order)
	{
		this.order = order;
	}
	public void setState(String state)
	{
		this.state = state;
	}
	
	
	/****ACCESSORS*****/
	
	public ResultSet getMovieList()
	{
		return movieList;
	}
	public String getOrder()
	{
		return order;
	}
	public String getOrderType()
	{
		return orderType;
	}
	public String getQuery()
	{
		return query;
	}
	public int getStart()
	{
		return start;
	}
	public String getCurrentGenre()
	{
		return currentGenre;
	}
	public String getMovieListType()
	{
		return movieListType;
	}
	public int getSizeOfMovieList()
	{
		return sizeOfMovieList;
	}
	public String getState()
	{
		return state;
	}
	public String getQueryFeaturedStars()
	{
		return queryFeaturedStars;
	}
	public ResultSet getMovieListFeaturedStars()
	{
		return movieListFeaturedStars;
	}
}
